import logging
from redis import StrictRedis


class Config(object):
    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"
    SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://root:mysql@127.0.0.1:3306/web_flask"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    redis_host = "127.0.0.1"
    redis_port = 6379
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(redis_host, redis_port)  # session 加到redis
    SESSION_USE_SIGNER = True  # 加密
    SESSION_PERMANENT = 1024 * 1024 * 24 * 2  # 2天
    LOG_LEVEL = logging.DEBUG


class Development(Config):
    '''开发环境下的配置'''
    DEBUG = True


class ProdutionConfig(Config):
    '''生产阶段的配置'''
    LOG_LEVEL = logging.ERROR


config = {
    "development": Development,
    "ProdutionConfig": ProdutionConfig
}
